<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">提现申请管理</div>
                </div>
                <div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xl am-cf">
                        <form id="form-search" class="toolbar-form" action="">
                            <input type="hidden" name="s" value="/<?= $request->pathinfo() ?>">
                            <div class="am-u-sm-12 am-u-md-3">
                                <div class="am-form-group">
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <?php if (checkPrivilege('finance.apply/export')): ?>
                                                <a class="j-export am-btn am-btn-success am-radius"
                                                   href="javascript:void(0);">
                                                    <i class="iconfont icon-daochu am-margin-right-xs"></i>订单导出
                                                </a>
                                            <?php endif; ?>

                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="am fr">

                                <div class="am-form-group am-fl">
                                    <?php $kp = $request->get('kp'); ?>
                                    <select name="kp"
                                            data-am-selected="{btnSize: 'sm', placeholder: '开票状态'}">
                                        <option value=""></option>
                                        <option value="-1"<?=$kp === '-1' ? 'selected' : '' ?>>全部</option>
                                        <option value="0" <?=$kp === '0'  ? 'selected' : '' ?>>不开票</option>
                                        <option value="1" <?=$kp === '1'  ? 'selected' : '' ?>>开票</option>
                                    </select>
                                </div>
                                <div class="am-form-group tpl-form-border-form am-fl">
                                    <input type="text" name="start_time"
                                           class="am-form-field"
                                           value="<?= $request->get('start_time') ?>" placeholder="请选择起始日期"
                                           data-am-datepicker>
                                </div>
                                <div class="am-form-group tpl-form-border-form am-fl">
                                    <input type="text" name="end_time"
                                           class="am-form-field"
                                           value="<?= $request->get('end_time') ?>" placeholder="请选择截止日期"
                                           data-am-datepicker>
                                </div>
                                <div class="am-form-group am-fl">
                                    <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                        <input type="text" class="am-form-field" name="search"
                                               placeholder="请输入商户名称"
                                               value="<?= $request->get('search') ?>">
                                        <div class="am-input-group-btn">
                                            <button class="am-btn am-btn-default am-icon-search" type="submit"></button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                            <thead>
                            <tr>
                                <th>申请号</th>
                                <th>服务商类型</th>
                                <th>申请商户</th>
                                <th>提现金额</th>
                                <th>是否开票</th>
                                <th>实际到账金额</th>
                                <th>品牌商审核状态</th>
                                <th>平台审核状态</th>
                                <th>备注</th>
                                <th>申请时间</th>

                            </tr>
                            </thead>
                            <tbody>
                            <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
                                <tr>
                                    <td class="am-text-middle"><?= $item['id'] ?></td>
                                    <td class="am-text-middle">
                                        <?php if ($item['type'] ==0) : ?>
                                            <span class="x-color-red">品牌商</span>
                                        <?php elseif ($item['type'] ==1 ) : ?>
                                            <span class="x-color-yellow">运营商</span>
                                        <?php else: ?>
                                            <span class="x-color-green">合伙人</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="am-text-middle">
                                        <?php if ($item['type'] ==0) : ?>
                                            <?= $item['company_name'];?>
                                        <?php elseif ($item['type'] ==1 ) : ?>
                                            <?= $item['company_name'] ? $item['company_name'] : $item['real_name'];?>
                                        <?php else: ?>
                                            <?= $item['real_name'];?>
                                        <?php endif; ?>
                                    </td>
                                    <td class="am-text-middle">   <?= $item['money'];?></td>
                                    <td class="am-text-middle">  <?= $item['isKaipiao'] ==0 ?'不开票' :'开票';   ?></td>
                                    <td class="am-text-middle"> <?= $item['isKaipiao'] ==0 ? (isset($item['real_money']) ?$item['real_money'] : 0) :$item['money']  ;   ?></td>
                                    <td class="am-text-middle">
                                        <?php if ($item['pps_status'] ==0) : ?>
                                            <span class="x-color-yellow">待通过</span>
                                        <?php elseif ($item['pps_status'] ==2 ) : ?>
                                            <span class="x-color-red">冻结中</span>
                                        <?php else: ?>
                                            <span class="x-color-green">通过</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="am-text-middle">
                                        <?php if ($item['sh_status'] ==0 && $item['pps_status'] ==0 ) : ?>
                                            <span class="x-color-yellow">待审核</span>
                                        <?php elseif ($item['sh_status'] ==0 && $item['pps_status'] ==1  ) : ?>
                                            <span class="x-color-yellow">待审核</span>
                                        <?php elseif ($item['sh_status'] ==0 && $item['pps_status'] ==2  ) : ?>
                                            <span class="x-color-red">待解冻</span>
                                        <?php elseif ($item['sh_status'] ==1 && $item['pps_status'] ==1  ) : ?>
                                            <span class="x-color-green">通过</span>
                                        <?php elseif ($item['sh_status'] ==2 && $item['pps_status'] ==1  ) : ?>
                                            <span class="x-color-red">已拒绝</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="am-text-middle"><?= $item['remark'] ?></td>
                                    <td class="am-text-middle"><?= $item['create_time'] ?></td>

                                </tr>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="11" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"><?= $list->render() ?></div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：<?= $list->total() ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        // 解冻
        var aurl = "<?= url('finance.apply/thaw') ?>";
        $('.j-active').delete('id', aurl, '确定要通过吗？');

        // 冻结
        var url = "<?= url('finance.apply/frozen') ?>";
        $('.j-delete').delete('id', url, '确定要决绝吗？');

        /**
         * 订单导出
         */
        $('.j-export').click(function () {
            var data = {};
            var formData = $('#form-search').serializeArray();
            $.each(formData, function () {
                this.name !== 's' && (data[this.name] = this.value);
            });
            window.location = "<?= url('finance.apply/export') ?>" + '&' + $.urlEncode(data);
        });

    });
</script>
